// asyncPackageComponent/components/hema_extra_popup/hema_extra_popup.js
const app = getApp();
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    show: {
      type: Boolean,
      value: false
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    pic: "",
    relative_path: "",
    income_type: ''
  },

  /**
   * 组件的方法列表
   */
  methods: {
    afterRead(event) {
      let {
        file
      } = event.detail;
      let urlStr = app.getNetAddresss('upload.uploadPic');
      wx.uploadFile({
        url: urlStr,
        filePath: file.url,
        name: 'file',
        formData: null,
        success: (res) => {
          let _res = JSON.parse(res.data);
          this.setData({
            pic: _res.data.img_url,
            relative_path: _res.data.img
          })
        },
      });
    },
    confirm() {
      this.triggerEvent('hemaExtraConfirm', {
        relative_path: this.data.relative_path,
        income_type: this.data.income_type,
        checkList: this.data.checkList,
        pay_type: this.data.pay_type
      })
    },
    close() {
      this.triggerEvent('close');
    }
  }
})